package com.exam.service.impl;

import com.exam.mapper.ReplayMapper;
import com.exam.pojo.Replay;
import com.exam.service.ReplayService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReplayServiceImpl implements ReplayService {
    @Resource
    private ReplayMapper replayMapper;
    @Override
    public int add(Replay replay) {
        return replayMapper.insert(replay);
    }

    @Override
    public PageInfo<Replay> queryByNamePage(Integer pageNum, Integer pageSize,String replayName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Replay> replays = replayMapper.queryByName(replayName);
        PageInfo<Replay> pageInfo = new PageInfo<>(replays);
        return pageInfo;
    }

    @Override
    public int updateById(Replay replay) {
        return replayMapper.updateById(replay);
    }

    @Override
    public int deleteById(Integer id) {
        return replayMapper.deleteById(id);
    }
}
